<template>
	<view>
		<view class="gradient-ramp">
			<view class="background" v-if="array1[0]">
				<!-- 前三名头像 -->
				<view class="background-gj thesame">
					<image :src="URL + array1[0].avatar" mode="" class="background-image"></image>
				</view>
				<view class="background-yj thesame">
					<image :src="URL + array1[1].avatar" mode="" class="background-image"></image>
				</view>
				<view class="background-jj thesame">
					<image :src="URL + array1[2].avatar" mode="" class="background-image"></image>
				</view>
				<!-- 前三名姓名/分数 -->
				<view class="score">
					<view class="score-j" style="margin-left: 4rpx;margin-top: 150rpx;">
						<view class="score-gj-name">
							{{array1[1].realName}}
						</view>
						<view class="score-j-score">
							{{array1[1].totalScore}}
						</view>
					</view>
					<view class="score-j" style="margin-top: 100rpx;">
						<view class="score-gj-name">
							{{array1[0].realName}}
						</view>
						<view class="score-j-score">
							{{array1[0].totalScore}}
						</view>
					</view>
					<view class="score-j" style="margin-top: 150rpx;">
						<view class="score-gj-name">
							{{array1[2].realName}}
						</view>
						<view class="score-j-score">
							{{array1[2].totalScore}}
						</view>
					</view>
				</view>
			</view>
			<!-- 其他人的排名 -->
			<view class="score-list">
				<view class="score-list-oneself" v-for="(item,index) in array2" :key="index">
					<view class="score-list-left">
						<view class="score-list-left-one">
							{{index + 4}}
						</view>
						<image :src="URL + item.avatar" mode=""></image>
						<view class="score-list-left-three">
							{{item.realName}}
						</view>
					</view>
					<view class="score-list-rigth">
							{{item.totalScore}}
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				URL: this.$store.state.user.URL,
				array1: [],
				array2: []
			};
		},
		onShow() {
			this.getpaiming()
		},
		methods: {
			async getpaiming() {
				const res = await uni.$http.get('/business/user/ranking')
				this.array1 = res.data.data.splice(0, 3)
				this.array2 = res.data.data
			}
		}
	}
</script>

<style lang="scss" scoped>
	.background-image{
		width: 140rpx;
		height: 140rpx;
		border-radius: 50%;
		margin-top: 76rpx;
		transform: translate(2rpx);
	}
	.gradient-ramp {
		background: linear-gradient(180deg, #16C1DB 0%, #F2FDFF 100%);
		height: 500rpx;
		padding: 72rpx 46rpx 0 46rpx;
		box-sizing: border-box;

	}
	
	.background {
		position: relative;
		height: 270rpx;
		width: 100%;
		margin-top: 150rpx;
		background: url('https://www.anhuimiller.com:441/profile/upload/appimg/status_icon/bjt.png') no-repeat;
		background-size: cover;

		.background-gj {
			top: -171rpx;
			left: 266rpx;
			background: url('https://www.anhuimiller.com:441/profile/upload/appimg/status_icon/gj.png') no-repeat;
			background-size: cover;
		}

		.background-yj {
			top: -124rpx;
			left: 50rpx;
			background-image: url('https://www.anhuimiller.com:441/profile/upload/appimg/status_icon/yj.png');
			background-size: cover;
		}

		.background-jj {
			top: -124rpx;
			right: 29rpx;
			background-image: url('https://www.anhuimiller.com:441/profile/upload/appimg/status_icon/jj.png');
			background-size: cover;
		}

		.thesame {
			position: absolute;
			height: 217rpx;
			width: 145rpx;
		}

		.score {
			display: flex;
			justify-content: space-around;

			.score-j {
				width: 140rpx;

				.score-gj-name {
					text-align: center;
					font-size: 32rpx;
					font-weight: 400;
					color: rgba(20, 58, 64, 1);
				}

				.score-j-score {
					text-align: center;
					margin-top: 32rpx;
					font-size: 32rpx;
					font-weight: 700;
					color: rgba(22, 193, 219, 1);
				}
			}

		}
	}

	.score-list {
		margin-top: 50rpx;

		.score-list-oneself {
			margin-top: 32rpx;
			display: flex;
			justify-content: space-between;
			align-items: center;

			.score-list-left {
				display: flex;
				justify-content: space-between;
				align-items: center;

				.score-list-left-one {
					width: 50rpx;
					text-align: center;
					opacity: 0.3;
					font-size: 32rpx;
					font-weight: 400;
					color: rgba(20, 58, 64, 1);
					margin-right: 40rpx;
				}

				image {
					margin-right: 24rpx;
					width: 96rpx;
					height: 96rpx;
					border-radius: 50%;
				}

				.score-list-left-three {
					font-size: 32rpx;
					font-weight: 400;
					color: rgba(20, 58, 64, 1);
				}
			}
		}

		.score-list-rigth {
			width: 80rpx;
			text-align: center;
			font-size: 24rpx;
			font-weight: 700;
			color: rgba(22, 193, 219, 1);
		}
	}
</style>